-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(schema): preserve top-level undefined keys in runtime config #4459
Conversation
β Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -720,14 +720,19 @@ export default { | |||
* @version 3 | |||
*/ | |||
runtimeConfig: { | |||
$resolve: (val: RuntimeConfig, get) => defu(val, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you e2e tested this? c12 and nitro use default multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we have a chance to map all NITRO_
and NUXT_
values into runtime config without explicit definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will need PRs to c12 & nitro. Issue is only at top-level IIRC so nested values with undefined are fine.
Tricky thing about automatic mapping is that it doesn't work both ways (ie. given a value in the config object, we can find the env variable name, but not vice versa).
For example, NUXT_BASE_URL maps to all of the following:
{
base: {
url: ''
},
baseURL: '',
baseUrl: '',
base_url: '',
BaseUrl: '',
// etc.
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can alternatively require fallback values in runtimeConfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make a convention work as top-level camelCase. using undefined
as default is not a solution I would keep forever... But let's merge it in last minutes. We can document to use empty string also for fallbacks instead of undefined.
π Linked issue
nuxt/nuxt#13769
β Type of change
π Description
This is a behaviour of
defu
that we have previously resolved in unjs/nitro#28 and #2456, but which has regressed...It will also need to be paired with a PR to nitro and c12.
π Checklist